package java_012_zuoye08;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class java01 {
	public static void main(String[] args) throws IOException {
		ArrayList<String> list = new ArrayList<>();
		FileReader fis=new FileReader("sort.txt");
		BufferedReader bis=new BufferedReader(fis);
		
		FileWriter fos = new FileWriter("finish.txt");
		BufferedWriter out = new BufferedWriter(fos);
		String line;
		while((line=bis.readLine())!=null){
			list.add(line);
		}
		bis.close();
		List<String> collect = list.stream().sorted().collect(Collectors.toList());
		System.out.println(collect);
		for(String str : collect){
			out.write(str);
			out.newLine();
		}
		out.close();
	}
}
